package com.yiwei.zxp.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.allen.library.SuperButton;
import com.yiwei.zxp.Application;
import com.yiwei.zxp.BussinessMainActivity;
import com.yiwei.zxp.R;
import com.yiwei.zxp.base.BaseActivity;
import com.yiwei.zxp.constant.Const;
import com.yiwei.zxp.util.Dialog;
import com.yiwei.zxp.util.PreferenceUtils;
import com.yiwei.zxp.util.UI;
import com.yiwei.zxp.util.Util;
import com.yiwei.zxp.view.V19FrameLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by xsooy-pc on 17-12-8.
 */

public class WechatLoginActivity extends BaseActivity {


    @BindView(R.id.btn_back)
    ImageView btnBack;
    @BindView(R.id.txt_right)
    TextView txtRight;
    @BindView(R.id.layout_title)
    V19FrameLayout layoutTitle;
    @BindView(R.id.img_icon)
    ImageView imgIcon;
    @BindView(R.id.txt_name)
    TextView txtName;
    @BindView(R.id.txt_info)
    TextView txtInfo;
    @BindView(R.id.btn_wechat_login)
    TextView btnWechatLogin;
    @BindView(R.id.btn_other_login)
    SuperButton btnOtherLogin;
    @BindView(R.id.btn_register)
    TextView btnRegister;
    @BindView(R.id.btn_change_account)
    TextView btnChangeAccount;
    @BindView(R.id.txt_agree)
    TextView txtAgree;
    private Unbinder unbiner;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login_wechat);
        initBar();
        unbiner = ButterKnife.bind(this);
        init();
    }

    private void init() {
        UI.setTvHtml(txtAgree, R.string.login_agree);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unbiner.unbind();
        unbiner = null;
    }

    @OnClick({R.id.txt_right, R.id.btn_back, R.id.btn_wechat_login, R.id.btn_other_login, R.id.btn_register, R.id.btn_change_account, R.id.txt_agree})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.txt_right:
                Dialog.showDefaultDialog(this, "提示", "请确认拨打" + Const.APP_CHINA_NAME + "官方电话", "拨打", "取消", false, new Dialog.DialogDefaultClickListener() {
                    @Override
                    public void confirm() {
                        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + PreferenceUtils.getString(Application.getInstance(), "service_phone", "")));
                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        startActivity(intent);
                    }

                    @Override
                    public void cancel() {

                    }
                });
                break;
            case R.id.btn_back:
                finish();
                break;
            case R.id.btn_wechat_login:
                Util.startActivity(this, BussinessMainActivity.class);
                finish();
                break;
            case R.id.btn_other_login:
                finish();
                break;
            case R.id.btn_register:
                Util.startActivity(this, RegisterActivity.class);
                finish();
                break;
            case R.id.btn_change_account:
                finish();
                break;
            case R.id.txt_agree:
                break;
        }
    }
}
